<template>
    <div class="goodlist">
        <el-row>
            <h1>{{grouptitle}}</h1>
        </el-row>
        <el-row :gutter="20">
            <router-link v-for="(items,index) in events" :to="{name:'details',params:{id:items.id}}" :key="index">
                <el-col :span="6" class="group">
                    <el-card :body-style="{ padding: '0px',border:0 }">
                        <img :src="items.img" class="image">
                        <div style="padding: 14px;">
                            <span>{{items.title}}</span>
                            <div class="bottom clearfix">
                                <time class="time">{{ items.update_time }}</time>
                            </div>
                        </div>
                    </el-card>
                </el-col>
            </router-link>
        </el-row>
    </div>
</template>
<script>
    import axios from 'axios'
    export default {
        data() {
            return {
                grouptitle: "美食大全",
                events: [
                    // {
                    //     pic: "https://qq897425998.github.io/Menu/images/index/wing.jpg",
                    //     name: "香辣鸡翅"
                    // },
                    // {
                    //     pic: "https://qq897425998.github.io/Menu/images/index/beef.jpg",
                    //     name: "芹菜炒牛肉"
                    // }, {
                    //     pic: "https://qq897425998.github.io/Menu/images/index/wing.jpg",
                    //     name: "香辣鸡翅"
                    // },
                    // {
                    //     pic: "https://qq897425998.github.io/Menu/images/index/beef.jpg",
                    //     name: "芹菜炒牛肉"
                    // },
                    // {
                    //     pic: "https://qq897425998.github.io/Menu/images/index/beef.jpg",
                    //     name: "芹菜炒牛肉"
                    // }, {
                    //     pic: "https://qq897425998.github.io/Menu/images/index/wing.jpg",
                    //     name: "香辣鸡翅"
                    // },
                    // {
                    //     pic: "https://qq897425998.github.io/Menu/images/index/beef.jpg",
                    //     name: "芹菜炒牛肉"
                    // }
                ]
            }
        },
        created() {
            axios({
                    method: 'get',
                    url: '/menus'
                })
                .then(res => {
                    console.log(res.data.data);
                    this.events = res.data.data;
                })
                .catch(() => {
                    console.log(error);
                })
        }
    }
</script>
<style scoped>
    .goodlist {
        width: 1000px;
        margin: 0 auto;
    }
    .image {
        width: 100%;
        display: block;
        height: 180px;
        overflow: hidden;
    }
    .el-card__body {
        padding: 0;
    }
    .group {
        margin-bottom: 20px;
        cursor: pointer;
    }
    h1 {
        margin: 30px 0;
        text-align: center;
    }
    .time {
        font-size: 13px;
        color: #999;
    }
    .bottom {
        margin-top: 6px;
    }
    .button {
        padding: 0;
        float: right;
    }
    .image {
        width: 100%;
        display: block;
    }
    .clearfix:before,
    .clearfix:after {
        display: table;
        content: "";
    }
    .clearfix:after {
        clear: both
    }
</style>
